//http://quote.eastmoney.com/center/gridlist.html#hs_a_board
function getStockBaseInfoList(params = {}, context = {}) {
	return uniCloud.httpclient.request("http://14.push2.eastmoney.com/api/qt/clist/get", {
		data: {
			cb: 'jQuery1124020589748748853132_1622518815104',
			pn: 1, // 页码
			pz: 20, // 页数
			po: 1,
			np: 1,
			ut: 'bd1d9ddb04089700cf9c27f6f7426281',
			fltt: 2,
			invt: 2,
			fid: 'f3',
			fs: 'm:0 t:6,m:0 t:80,m:1 t:2,m:1 t:23',
			fields: 'f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152',
			_: 1622518815114,
			...params
		},
		method: "get"
	})
}
/**
	
    ==数据提取网(腾讯证券)==
    https://gu.qq.com/sz000100/gp
    ==接口 ======
    https://proxy.finance.qq.com/ifzqgtimg/appstock/app/newfqkline/get
    ==参数=======
    {
     (sz000100 : 股票编码 | day : k线类型 |2004-01-01:开始年月日| 2005-12-31:结束年月日 | [320,640] : 数据量  )
     (默认一年数据 : param=sz000100,day,,,960)
     param="sz000100,[day,week,month],2004-01-01,2005-12-31,640,qfq", 
     }
    ==响应数据类型==
     Content-Type: text/html; charset=UTF-8
    ==响应数据====
   	 data:{
   		 "sz000100":{
   			 "[qfqday,qfqweek,qfqmonth]":[
   				 [	 
   					 "2021-06-02", 当前日期
   					 "8.15", 开盘价
   					 "8.01", 最新价
   					 "8.16", 最高价
   					 "8.00", 最低价
   					 "2764520.00", 成交量(手)
   					 {},
   					 "2.14", 换手率
   					 "222394.00", 成交额
   					 ""
   				 ]
   			 ]
   		 }
   	 }
    */
   
// 插入日，周，月线
function getStockDWMKLine({
	symbol = "",
	type = "day",
	start = "",
	end = "",
	cycle = "640"
} = {}, params = {}, context = {}) {
	return uniCloud.httpclient.request("https://proxy.finance.qq.com/ifzqgtimg/appstock/app/newfqkline/get", {
		data: {
			param : `${symbol},${type},${start},${end},${cycle},qfq`,
			...params
		},
		method: "get",
		dataType:"json"
	})
}
// 日k
function getStockDayKLine({
	code = "",
	start = "",
	end = "",
	cycle = "640"
}, params = {}, context = {}) {
	return uniCloud.httpclient.request("https://proxy.finance.qq.com/ifzqgtimg/appstock/app/newfqkline/get", {
		data: {
			param : `${code},day,${start},${end},${cycle},qfq`,
			...params
		},
		method: "get",
		dataType:"json"
	})
}
// 周 k
function getStockWeekKLine(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://proxy.finance.qq.com/ifzqgtimg/appstock/app/newfqkline/get", {
		data: {
			param :"sz000100,week,,,640,qfq",
			...params
		},
		method: "get"
	})
}
// 月 k
function getStockMonthKLine(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://proxy.finance.qq.com/ifzqgtimg/appstock/app/newfqkline/get", {
		data: {
			param : "sz000100,month,,,640,qfq",
			...params
		},
		method: "get"
	})
}
/**
    ==数据提取网(腾讯证券)==
    https://gu.qq.com/sz000100/gp
    ==接口 ======
    https://web.ifzq.gtimg.cn/appstock/app/day/query
    ==参数=======
    {	
		**股票编码**
		code: sz000100 
     }
    ==响应数据类型==
     Content-Type: text/html; charset=UTF-8
    ==响应数据====
   	 data:{
   		 "sz000100":{
   			 data:[
				 {
					 **1500:三点 | 8.01 :当前价格 |2764520 成交量**
					 data:["1500 8.01 2764520"],
					 **20210602: 日期**
					 date:"20210602",
					 **昨日收盘价**
					 prec: "8.16"
				 }, {
					 data:[""],
					 date:"20210601",
					 prec: "8.08"
				 }, {
					 data:[""],
					 date:"20210531",
					 prec: "8.12"
				 }, {
					 data:[""],
					 date:"20210528",
					 prec: "8.36"
				 }, {
					 data:[""],
					 date:"20210527",
					 prec: "8.22"
				 },
			 ]
   		 }
   	 }
    */
//五日
function getStockFiveDay(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://web.ifzq.gtimg.cn/appstock/app/day/query", {
		data: {
			code: "sz000100",
			...params
		},
		method: "get"
	})
}
/**
      ==数据提取网(腾讯证券)==
      https://gu.qq.com/sz000100/gp
      ==接口 ======
      https://ifzq.gtimg.cn/appstock/app/kline/mkline
      ==参数=======
      {	
  		**sz000100:股票编码,m5:分钟线类型,2021-06-02(当前时期往前推多少个周期),[320,640]:周期**
  		param: sz000100,[m5,m30,m60],2021-06-02,320
       }
      ==响应数据类型==
       Content-Type: text/html; charset=UTF-8
      ==响应数据====
     	 data:{
     		 "sz000100":{
				 **202106021500:日期|8.02:开盘|8.01:收盘|8.02:最高|8.00:最低|492399.00:成交量(手)*
     			 data:["202106021500", "8.02", "8.01", "8.02", "8.00", "492399.00", {}, "38.18"]
     		 }
     	 }
      */
function getStockM5(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://ifzq.gtimg.cn/appstock/app/kline/mkline", {
		data: {
			code: "sz000100",
			...params
		},
		method: "get"
	})
}

function getStockM30(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://ifzq.gtimg.cn/appstock/app/kline/mkline", {
		data: {
			code: "sz000100",
			...params
		},
		method: "get"
	})
}

function getStockM60(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://ifzq.gtimg.cn/appstock/app/kline/mkline", {
		data: {
			code: "sz000100",
			...params
		},
		method: "get"
	})
}
/**
      ==数据提取网(腾讯证券)==
      https://stockapp.finance.qq.com/mstats/#mod=list&id=ssa&module=SS&type=ranka
      ==接口 ======
      https://stock.gtimg.cn/data/index.php
      ==参数=======
      {	
  		appn: "rank",
  		t: "ranka/chr",
		**当前页**
  		
		p: 1,
		o: 0,
		**页数**
  		l: 40,
  		v: "list_data"
       }
      ==响应数据类型==
       Content-Type: text/html; charset=UTF-8
      ==响应数据====
     	 var list_data={t:'ranka/chr',p:110,total:2195,l:2,o:0,data:'sh605183,sz000731'};
      */
function getStockSymbols(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://stock.gtimg.cn/data/index.php", {
		data: {
			appn: "rank",
			t: "ranka/chr",
			p: 1,
			o: 0,
			l: 40,
			v: "list_data",
			...params
		},
		method: "get"
	})
}
/**
      ==数据提取网(腾讯证券)==
      https://stockapp.finance.qq.com/mstats/#mod=list&id=ssa&module=SS&type=ranka
      ==接口 ======
	   **code直接拼接后面**
      https://qt.gtimg.cn/q=sh688613,sh600539
      ==参数=======
      ==响应数据类型==
       Content-Type: text/html; charset=UTF-8
      ==响应数据====
     	v_sh688613="1~奥精医疗~688613~114.00~126.90~125.95~6359782~2681973~3677810~114.00~1272~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20210603150624~-12.90~-10.17~128.96~112.59~114.00/6359782/760340264~6359782~76034~23.21~142.16~~128.96~112.59~12.90~31.24~152.00~13.31~152.28~101.52~1.09~1272~119.55~210.04~170.89~~~~76034.0264~2.2800~200~B~GP-A-KCB~593.85~3.19~0.00~16.69~12.49~137.85~78.00~593.85~593.85~593.85~27399170~133333330";
		 v_sh600539="1~狮头股份~600539~8.42~7.65~7.60~51820~12931~38889~8.42~24371~8.40~41~8.37~2~8.31~12~8.30~4~0.00~0~0.00~0~0.00~0~0.00~0~0.00~0~~20210603150608~0.77~10.07~8.42~7.56~8.42/51820/42602515~51820~4260~2.25~163.40~~8.42~7.56~11.24~19.37~19.37~4.55~8.42~6.89~3.24~24430~8.22~119.30~173.74~~~0.35~4260.2515~0.0000~0~ ~GP-A~14.56~17.76~0.00~2.79~4.13~8.42~5.30~16.30~14.71~29.54~230000000~230000000";
      */
function getStockInfos(params = {}, context = {}) {
	return uniCloud.httpclient.request("https://qt.gtimg.cn/q=sh688613,sh600539", {
		data: {},
		method: "get"
	})
}
/**
      ==数据提取网(新浪财经)==
      http://vip.stock.finance.sina.com.cn/mkt/#hs_a
      ==接口 ======
	   **code直接拼接后面**
      http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData
      ==参数=======
	  {		**页码**
	    	page: 1,
			**页数**
	    	num: 40,
			**排序字段**
	    	sort: symbol,
			**倒序**
	    	asc: 1,
			**模块**
			**[sh_a:沪A,sh_b:沪B,sz_a:深A,sz_b:深B,hs_a:沪深A,hs_b沪深B]**
	    	node: sh_a,
	    	symbol: 
	    	_s_r_a: "init"
	   }
      ==响应数据类型==
       Content-Type: text/html; charset=UTF-8
      ==响应数据====
     	[
			{
			 **标识**
			"symbol": "sh600000",
			**编码**
			"code": "600000",
			**名称**
			"name": "浦发银行",
			**最新价**
			"trade": "10.230",
			**涨跌额**
			"pricechange": 0.01,
			**涨跌幅(0.098%)**
			"changepercent": 0.098,
			**买入**
			"buy": "10.230",
			**卖出**
			"sell": "10.240",
			**昨收**
			"settlement": "10.220",
			**开盘价**
			"open": "10.210",
			**最高价**
			"high": "10.320",
			**最低价**
			"low": "10.180",
			 **成交量(手)**
			"volume": 52244908,
			**成交额(万)**
			"amount": 535599653,
			**时间**
			"ticktime": "15:00:00",
			**市盈率**
			"per": 5.441,
			**市净率**
			"pb": 0.55,
			**市值**
			"mktcap": 30027243.733476,
			"nmc": 30027243.733476,
			**换手率**
			"turnoverratio": 0.17799
			}
     	]
      */
function getStockHQNodeData(params = {}, context = {}) {
	return uniCloud.httpclient.request(
		"http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData", {
			data: {
				page: 1,
				num: 1,
				sort: 'symbol',
				asc: 1,
				node: "hs_a",
				symbol:"",
				 _s_r_a: "page",
				...params
				
			},
			method: "get",
			dataType:"json"
		})
}
/**
	  ==数据提取网(新浪财经)==
	  http://vip.stock.finance.sina.com.cn/mkt/#hs_a
	  ==接口 ======
	  http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeStockCount
	  ==参数=======、
	  {	  	
		  **模块**
		  [sh_a:沪A,sh_b:沪B,sz_a:深A,sz_b:深B,hs_a:沪深A,hs_b沪深B]
		  node=sh_a
	   }
	  ==响应数据类型==
	   Content-Type: text/html; charset=UTF-8
	  ==响应数据====
	 	"1898"
	  */
function getStockCount(params = {}, context = {}) {
	return uniCloud.httpclient.request(
		"http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeStockCount ", {
			data: {
				node: "hs_a",
				...params
			},
			method: "get",
			dataType:"json"
		})
}
module.exports = {
	getStockBaseInfoList,
	getStockCount,
	getStockHQNodeData,
	getStockDWMKLine
}
